function find(s:string):string;

var
	i,kk,j,k,ans,n:longint;

begin
s := s + s;
n := length(s);
i := 1;
ans := 0;
kk := n shr 1;
while (i <= kk) do begin
	ans := i;
	j := i + 1;
	k := i;
	while (j <= n) and (s[k] <= s[j]) do begin
		if s[k] < s[j] then k := i else inc(k);
		inc(j);
	end;
	while i <= k do inc(i, j - k);
end;
result := copy(s, ans, kk);
end;